package com.bookstore.spring.dao;


import com.bookstore.spring.pojo.User;
import com.bookstore.spring.util.MybatisSessionFactory;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Admin on 2016/8/4.
 */
@Repository
public class UserMap {
    String str = "com.bookstore.spring.mapper.UserMapper.";

    public User getUserByName(String username) {
        String statement = str + "getUserByName";
        User user = MybatisSessionFactory.getSession().selectOne(statement, username);
        return user;
    }

    public User getUserNaPa(String username, String password) {
        String statement = str + "getUserNaPa";
        Map<String, String> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        User user = MybatisSessionFactory.getSession().selectOne(statement, map);
        return user;
    }

    public void save(User user) {
        String statement = str + "save";
        MybatisSessionFactory.getSession().insert(statement, user);
    }
}
